﻿using System;



class GradeCalculator

{

    static void Main()

    {

        Console.WriteLine("学生成绩等级评定系统");

        Console.WriteLine("       ");



        while (true)

        {

            try

            {

                Console.Write("\n请输入学生成绩（0-100之间，输入-1退出）：");

                string input = Console.ReadLine();

                if (input == "-1")

                {

                    Console.WriteLine("程序已退出。");

                    break;

                }

                if (double.TryParse(input, out double score))

                {

                    if (score >= 0 && score <= 100)

                    {

                        string grade = GetGrade(score);

                        Console.WriteLine($"成绩 {score} 分的等级为：{grade}");

                    }

                    else

                    {

                        Console.WriteLine("错误：成绩必须在0-100之间！");

                    }

                }

                else

                {

                    Console.WriteLine("错误：请输入有效的数字！");

                }

            }

            catch (Exception ex)

            {

                Console.WriteLine($"发生错误：{ex.Message}");

            }

        }

    }

    static string GetGrade(double score)

    {

        if (score >= 90)

        {

            return "A";

        }

        else if (score >= 60) // 60-89分

        {

            return "B";

        }

        else // 60分以下

        {

            return "C";

        }

    }

}